"use strict";
cc._RF.push(module, '427a0D9ekFMu57VSv5uEPAA', 'start');
// scripts/scenes/start.ts

"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
    for (var r = Array(s), k = 0, i = 0; i < il; i++)
        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
            r[k] = a[j];
    return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var gameEngine_1 = require("../engines/gameEngine");
var gameConfig_1 = require("../engines/configs/gameConfig");
var MainRoot_1 = require("../Game/MainRoot");
var physics_tool_1 = require("../engines/libs/physics_tool");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
function beforeGameRun() {
    // 抗锯齿 要在cc.game.run前调用 webgl 才生效
    cc.macro.ENABLE_WEBGL_ANTIALIAS = true;
    // 是否开启多点触摸
    cc.macro.ENABLE_MULTI_TOUCH = true;
    //
    // console.log("引擎配置初始化");
}
beforeGameRun();
var start = /** @class */ (function (_super) {
    __extends(start, _super);
    function start() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    // LIFE-CYCLE CALLBACKS:
    start.prototype.onLoad = function () {
        var uiRoot = this.node.parent.getChildByName("UIRoot");
        cc.game.addPersistRootNode(uiRoot);
        MainRoot_1.default.SetUIRoot(uiRoot);
    };
    start.prototype.start = function () {
        var _this = this;
        //日志服最先
        if (gameConfig_1.default.LOG_SERVICE_OPEN) {
            gameEngine_1.default.getServices()
                .logSrv.loadService()
                .then(function () {
                gameEngine_1.default.getServices()
                    .logSrv.onLoadedService()
                    .then(function () {
                    _this.onReady();
                });
            });
        }
        else {
            this.onReady();
        }
    };
    start.prototype.onReady = function () {
        // console.log("<start> 场景");
        if (!cc.sys.isNative) {
            console.log("cocos webgl");
        }
        else {
            console.log("cocos 2d-x");
        }
        //初始化cocos引擎配置
        this.initEngineConfig();
        //打印cocos引擎配置
        // this.printEngineConfig();
        //
        this.goLoading();
    };
    start.prototype.initEngineConfig = function () {
        cc.debug.setDisplayStats(false);
        physics_tool_1.default.openCollision(false);
        physics_tool_1.default.openPhysics(true);
        var manager = cc.director.getCollisionManager();
        manager.enabled = true;
        manager.enabledDebugDraw = false;
        cc.director.getPhysicsManager().enabledAccumulator = true;
        // 物理步长，默认 FIXED_TIME_STEP 是 1/60
        cc.PhysicsManager.FIXED_TIME_STEP = 1 / 60;
    };
    //
    start.prototype.printEngineConfig = function () {
        console.group("cocos引擎配置");
        console.log("是否开启抗锯齿", cc.view.isAntiAliasEnabled(), cc.macro.ENABLE_WEBGL_ANTIALIAS);
        console.log("是否开启多点触摸", cc.macro.ENABLE_MULTI_TOUCH);
        console.log("是否显示左下角调试信息", cc.debug.isDisplayStats());
        console.log("是否开启瓦片地图的自动裁减功能", cc.macro.ENABLE_TILEDMAP_CULLING);
        console.log("单次批处理渲染的顶点数量", cc.macro.BATCH_VERTEX_COUNT);
        console.log("Canvas背景是否支持 alpha 通道", cc.macro.ENABLE_TRANSPARENT_CANVAS);
        console.log.apply(console, __spreadArrays(["引擎支持的图片格式"], cc.macro.SUPPORT_TEXTURE_FORMATS));
        console.groupEnd();
    };
    start.prototype.goLoading = function () {
        gameEngine_1.default.loadScene("loading");
    };
    start = __decorate([
        ccclass
    ], start);
    return start;
}(cc.Component));
exports.default = start;

cc._RF.pop();